// VaxVoIP.h: interface for the CVaxVoIP class.
//
//////////////////////////////////////////////////////////////////////


#if !defined(AFX_VaxVoIP_H__017BA040_906C_45E4_B6E6_F86A3960ADA4__INCLUDED_)
#define AFX_VaxVoIP_H__017BA040_906C_45E4_B6E6_F86A3960ADA4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif

#include "../VaxSIPUserAgentLib/VaxSIPUserAgentLib.h"

class CVaxVoIPDlg;
class CVaxErrorMsg;

class CVaxSIPUserAgent : public CVaxSIPUserAgentLib  
{

public:

	CVaxSIPUserAgent(CVaxVoIPDlg* pMianDlg);
	~CVaxSIPUserAgent();

public:

	CVaxVoIPDlg* m_pMainDlg;
	CVaxErrorMsg* m_pVaxErrorMsg;

private:

	BOOL m_bEnableREC;

public:

	int m_nTotalLine;

	int m_nAudioInDevice;
	int m_nAudioOutDevice;
		
public:	

	BOOL VaxInitObject(LPCTSTR sUserName, LPCTSTR sLogin, LPCTSTR sLoginPwd, LPCTSTR sDisplayName, LPCTSTR sDomainRealm, LPCTSTR sSIPProxy, BOOL bUseSoundDevice, int nTotalLine);
	void UnInitialize();

	BOOL RegisterToProxyREC(BOOL bRegister, int nExpire, LPCTSTR sUserName, LPCTSTR sLoginId, LPCTSTR sLoginPwd, LPCTSTR sDisplayName, LPCTSTR sDomainRealm, LPCTSTR sProxySIP);
	void UnRegisterToProxyREC();

	void SetActiveAudioInDevice(int nAoudioInDevice);
	void SetActiveAudioOutDevice(int nAoudioOutDevice);
	
	int GetActiveAudioInDevice();
	int GetActiveAudioOutDevice();

	int GetTotalLine();

private:

	void ShowErrorMessage();
	void OnStatusMsgREC(int nLineNo);
	
	BOOL OpenLines(int nTotalNoOfLine);
	void DialCallToREC(int nLineNo);
	
public:

	BOOL DialCall(int nLineNo, LPCTSTR sDialNo);
	BOOL AcceptCall(int nLineNo, LPCTSTR sCallId);
	BOOL RejectCall(LPCTSTR sCallId);

	BOOL ForwardCall(BOOL bEnable, LPCTSTR sToUserName);
	BOOL TransferCallEx(int nLineNo, LPCTSTR sToUserName);
	BOOL JoinTwoLine(int nLineNoA, int nLineNoB);
 
	BOOL IsRecording(int nLineNo);
	BOOL ResetRecording(int nLineNo);
	BOOL StopRecording(int nLineNo);
	BOOL StartRecording(int nLineNo, int nRecordVoice, BOOL bRecordCompress);
	BOOL SaveRecordingToWaveFile(int nLineNo, LPCTSTR sFileName);
	BOOL PlayWaveOpen(int nLineNo, LPCTSTR sFileName);

	BOOL PlayWaveSkipTo(int nLineNo, int nSeconds);
	BOOL PlayWavePause(int nLineNo);
	BOOL PlayWaveStart(int nLineNo, BOOL bListen);
	BOOL PlayWaveStop(int nLineNo);

	BOOL IsWaveFilePlaying(int nLineNo);

	BOOL SetLicenceKey(LPCTSTR sLicenceKey);

	BOOL RegisterToProxy(int nExpire);
	BOOL EnableKeepAlive(int nSeconds);

	BOOL MuteLineSPK(int nLineNo, BOOL bCheckMuteLineSPK);
	BOOL MuteLineMIC(int nLineNo, BOOL bCheckMuteLineMIC);

	BOOL LineVoiceChannelSPK(int nLineNo, int nSpkListenChannel);
	BOOL ConfAllowLine(int nLineNo, BOOL bCheckAllowListenConf, BOOL bCheckAllowSpeakConf);

	BOOL MuteSpk(BOOL bMute);
	BOOL MuteMic(BOOL bMute);

	BOOL UnHoldLine(int nLineNo);
	BOOL HoldLine(int nLineNo);

	BOOL ChatAddContact(LPCTSTR sUserName);
	BOOL ChatRemoveContact(LPCTSTR sUserName);
	
	BOOL ChatSendMessageTyping(LPCTSTR sUserName, int nUserValue32bit);
	BOOL ChatSendMessageText(LPCTSTR sUserName, LPCTSTR sMsgText, int nMsgType, int nUserValue32bit);
	
	BOOL ChatSetMyStatus(int nStatusId);

	BOOL VoiceChanger(int nPitch);

	BOOL PlayAddPCM(int nLineNo, char* pDataPCM, DWORD dwSizePCM);
	BOOL PlayResetPCM(int nLineNo);
	BOOL CaptureStreamPCM(int nLineNo, BOOL bEnable);

	BOOL DetectAMD(int nLineNo, BOOL bEnable, int nAnalysisTime, int nSilenceTime, int nSilenceCount);

	BOOL SelectVoiceCodec(int nCodecNo);
	BOOL DeselectVoiceCodec(int nCodecNo);

	BOOL EnableEchoNoiseCancellation();
	BOOL DisableEchoNoiseCancellation();

	BOOL EnableAGC(int nLevel);
	BOOL DisableAGC();

	BOOL EnableMicBoost();
	BOOL DisableMicBoost();
	BOOL IsMicBoostEnable();

	BOOL DigitDTMF(int nLineNo, LPCTSTR sDigit);
	BOOL EnableForceInbandDTMF(int nLineNo);
	BOOL DisableForceInbandDTMF(int nLineNo);

	BOOL IsLineOpen(int nLineNo);
	BOOL IsLineHold(int nLineNo);
	BOOL IsLineBusy(int nLineNo);
	BOOL IsLineConnected(int nLineNo);

	BOOL Disconnect(int nLineNo);
	BOOL CryptCOMM(BOOL bEnable, LPCTSTR sRemoteIP, int nRemotePort);
		
public:

	BOOL m_bActivateVideoDevice;
	BOOL m_nVideoDeviceId;
	BOOL m_nVideoQuality;

private:

	void CaptureVideoDevice();

public:

	BOOL SelectVideoCodec(int nCodecNo);
	BOOL DeselectVideoCodec(int nCodecNo);
	
	void SetActiveVideoDevice(int nDeviceId);
	void ActivateVideoDevice(BOOL bActivate);
	void SetVideoQuality(int nQuality);

	void ActivateQosRTP(int nPriorityQos);
	void DeactivateQosRTP();

public:

	void OnFailToTransfer(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);

	void OnTryingToRegister();
	void OnFailToRegisterEx(int nStatusCode, LPCTSTR sReasonPhrase);
	void OnSuccessToRegister();

	void OnTryingToReRegister();
	void OnFailToReRegisterEx(int nStatusCode, LPCTSTR sReasonPhrase);
	void OnSuccessToReRegister();
	
	void OnTryingToUnRegister();
	void OnFailToUnRegister();
	void OnSuccessToUnRegister();
		
	void OnConnecting(int nLineNo);
	void OnSuccessToConnect(int nLineNo, LPCTSTR sToRTPIP, UINT nToRTPPort);
	void OnFailToConnect(int nLineNo);
		
	void OnDisconnectCall(int nLineNo);
	void OnCallTransferAccepted(int nLineNo);
	void OnPlayWaveDone(int nLineNo);
	void OnDTMFDigit(int nLineNo, LPCTSTR sDigit);
	
	void OnMsgNOTIFY(LPCTSTR sMsg);
	void OnVoiceMailMsg(BOOL bIsMsgWaiting, DWORD dwNewMsgCount, DWORD dwOldMsgCount, DWORD dwNewUrgentMsgCount, DWORD dwOldUrgentMsgCount, LPCTSTR sMsgAccount);

	void OnIncomingCall(LPCTSTR sCallId, LPCTSTR sDisplayName, LPCTSTR sUserName, LPCTSTR sFromURI, LPCTSTR sToURI);
	void OnIncomingCallRingingStart(LPCTSTR sCallId);
	void OnIncomingCallRingingStop(LPCTSTR sCallId);
		
	void OnProvisionalResponse(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);
	void OnRedirectionResponse(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase, LPCTSTR sContact);
	void OnRequestFailureResponse(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);
	void OnServerFailureResponse(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);
	void OnGeneralFailureResponse(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);

	void OnIncomingDiagnostic(LPCTSTR sMsgSIP, LPCTSTR sFromIP, UINT nFromPort);
	void OnOutgoingDiagnostic(LPCTSTR sMsgSIP, LPCTSTR sToIP, UINT nToPort);

	void OnSessionLostEvent(int nLineNo);
	
	void OnSuccessToHold(int nLineNo);
	void OnTryingToHold(int nLineNo);
	void OnFailToHold(int nLineNo);

	void OnSuccessToUnHold(int nLineNo);
	void OnTryingToUnHold(int nLineNo);
	void OnFailToUnHold(int nLineNo);

	void OnChatContactStatus(LPCTSTR sUserName, int nStatusId);
	
	void OnChatSendMsgTextSuccess(LPCTSTR sUserName, LPCTSTR sMsgText, int nUserValue32bit);
	void OnChatSendMsgTextFail(LPCTSTR sUserName, int nStatusCode, LPCTSTR sReasonPhrase, LPCTSTR sMsgText, int nUserValue32bit);
	
	void OnChatSendMsgTypingSuccess(LPCTSTR sUserName, int nUserValue32bit);
	void OnChatSendMsgTypingFail(LPCTSTR sUserName, int nStatusCode, LPCTSTR sReasonPhrase, int nUserValue32bit);

	void OnChatRecvMsgText(LPCTSTR sUserName, LPCTSTR sMsgText);
	void OnChatRecvMsgTypingStart(LPCTSTR sUserName);
	void OnChatRecvMsgTypingStop(LPCTSTR sUserName);

	void OnVoiceStreamPCM(int nLineNo, char* pDataPCM, int nSizePCM);
	void OnDetectedAMD(int nLineNo, BOOL bIsHuman);

	void OnHoldCall(int nLineNo);
	void OnUnHoldCall(int nLineNo);

	void OnVideoRemoteShowStart(int nLineNo);
	void OnVideoRemoteShowStop(int nLineNo);
	void OnVideoRemoteShowRGB(int nLineNo, BYTE* pFrameRGB, DWORD dwFrameSize, DWORD dwFrameWidth, DWORD dwFrameHeight);
	void OnVideoDeviceShowRGB(int nDeviceId, BYTE* pFrameRGB, DWORD dwFrameSize, DWORD dwFrameWidth, DWORD dwFrameHeight);

	/////////////////////////////////////////////////////////////////////////////////////////

	void OnTryingToRegisterREC();
	void OnFailToRegisterREC(int nStatusCode, LPCTSTR sReasonPhrase);
	void OnSuccessToRegisterREC();

	void OnTryingToReRegisterREC();
	void OnFailToReRegisterREC(int nStatusCode, LPCTSTR sReasonPhrase);
	void OnSuccessToReRegisterREC();
	
	void OnTryingToUnRegisterREC();
	void OnFailToUnRegisterREC();
	void OnSuccessToUnRegisterREC();
		
	void OnServerConnectingREC(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);
	void OnServerConnectedREC(int nLineNo);
	void OnServerFailedREC(int nLineNo, int nStatusCode, LPCTSTR sReasonPhrase);
	void OnServerHungupREC(int nLineNo);
};

#endif
